/**
 * This class represents an Ambient Orb device.
 */
package org.hackystat.ui.orb.client.common;

import java.io.Serializable;

/**
 * This class represents an Ambient Orb device.
 * @author David J. Nickles
 *
 */
public class AmbientOrb implements Serializable {

  /**  {@literal} serialVersionUID the serialized Id. */
  private static final long serialVersionUID = -7151131113197902328L;
  /** {@literal} SERVER the default Ambient service URL. */  
  public static final String SERVER = 
    "http://www.myambient.com:8080/java/my_devices/submitdata.jsp";
  /** {@literal} QUERYMARK indicator. */  
  public static final String QUERYMARK = "?";
  /** {@literal} AMPERSAND indicator. */  
  public static final String AMPERSAND = "&";
  
  private String devID; // required.
  private String color; // required.
  private String anim; // optional (defaults to "none").
  private String comment; // optional (defaults to "no comment").

  /**
   * Constructs a valid Ambient Orb state.
   */
  public AmbientOrb() {
    super();
    this.devID = "XXX-XXX-XXX";
    this.color = "0";
    this.anim = "9";
    this.comment = "Default Constructor.";
  }
  
  /**
   * Constructs a valid Ambient Orb state.
   * @param devID the Ambient Orb device Id.
   * @param color the color cardinal.
   * @param anim the animation cardinal.
   * @param comment a comment to attach to this data state.
   */
  public AmbientOrb(String devID, int color, int anim, String comment) {
    super();
    this.devID = devID;
    this.color = String.valueOf(color);
    this.anim = String.valueOf(anim);
    this.comment = comment;
  }

  /**
   * @return the query portion of the URL.
   */
  private String getQuery() {
    return QUERYMARK + "devID=" + this.devID + AMPERSAND + "anim=" + this.anim 
      + AMPERSAND + "color=" + this.color + AMPERSAND + "comment=" + this.comment;
  }

  /**
   * @return the URL that sets the Orb state.
   */
  public String getUrl() {
    return SERVER + getQuery();
  }
  
  /**
   * @return the devID
   */
  public String getDevID() {
    return devID;
  }

  /**
   * @param devID the devID to set
   */
  public void setDevID(String devID) {
    this.devID = devID;
  }

  /**
   * @return the color
   */
  public String getColor() {
    return color;
  }

  /**
   * @param color the color to set
   */
  public void setColor(String color) {
    this.color = color;
  }

  /**
   * @return the anim
   */
  public String getAnim() {
    return anim;
  }

  /**
   * @param anim the anim to set
   */
  public void setAnim(String anim) {
    this.anim = anim;
  }

  /**
   * @return the comment
   */
  public String getComment() {
    return comment;
  }

  /**
   * @param comment the comment to set
   */
  public void setComment(String comment) {
    this.comment = comment;
  }
}
